import {createStore} from 'vuex'

export default createStore({
  state: {
    title: window.eason.title,
    token: localStorage.getItem('token') || null,
    userInfo: {}
  },
  mutations: {
    token(state, token) {
      if (token === null) {  //修复设置为null会设置为字符串的'null'
        localStorage.removeItem('token')
        state.token = null
      } else {
        localStorage.setItem('token', token)
        state.token = token
      }
    },
    userInfo(state, payload) {
      state.userInfo = payload
    }
  },
  actions: {},
  modules: {}
})
